<!DOCTYPE html>
<html>
  <head>
<div th:include="base-libs :: base-libs" />
    <title>团队详细</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <style>
    	body{
    		overflow-x:hidden;
    		overflow-y:auto;
    		padding: 0px 10px;
    	}
    	#foot button{
    		margin-left:10px;
    	}
    	.title{
			height:40px;
			line-height:40px;
			font-size:16px;
			background:#F7F9FB;
			position:relative;
			margin-left:0;
			padding-left:5px;
		}
		.spanBtn{
			font-weight: bold;
			color: blue;
			cursor:pointer;
		}
    </style>
    
    <script>
    	var tdManagerData;
    	var isBoss = StoreCache.removeCache("isBoss");
    	$(function(){
    		initView();
    		initData();
    	})
    	
    	function initView(){
    	    $("[disabled=disabled]").css("color","#000");

    		/* 成员列表 */
    		$("#cylbTable").datagrid({
				idField : "USERID",
				uniqueId: "USERID",
				striped : true,
				border:false,
				fitColumns:true,
				fit:true,
				singleSelect: true,
				columns : [[
						{field:'XM', title:'医生姓名', width: 80, align: 'center'}
					,{field : 'SFZH',title : '身份证号', width: 80, align: 'center'}
					,{field:'YLJGMC', title:'第一执业机构', width: 80, align: 'center'}
					,{field:'TDJS', title:'团队角色', width: 80, align: 'center',formatter:function(value,row,index){
						var jsObj = {'1':'团队长','2':'普通成员','3':'团队助手'};
						return jsObj[value];
					}}
					,{field:'RTSJ', title:'入团时间', width: 80, align: 'center',formatter:function(value,row,index){
						row.RTSJ = row.RTSJ.substring(0,10);
						return value.substring(0,10);
					}}
					,{field:'SJHM', title:'手机号码', width: 80, align: 'center'}
					,{field:'USERID', title:'详细', width: 60, align: 'center',formatter:function(value,row,index){
						//return '<a href="javascript:void(0)" onclick=queryYsxx("'+value+'")>医生详细</a>';
                        return '<span class="spanBtn" onclick="queryYsxx(\'' + value + '\')">医生详细</span>';
					}}
				]],
				method : "post",
				url : contextRoot + "tdgl/queryTdcylbAll.service",
				onBeforeLoad : function(params) {
					params["TDID"] = $("#cylbTable").data("TDID");
					if(params["TDID"]){
						return params;
					}else{
						return false;
					}
				},
				onLoadSuccess: function(data){
					$("#myBox").css("height",(data.rows.length)*37+83);
					$("#myLayout").layout("resize");
 				},

			});
    		
    		
    	}
    	
        /** 查询医生详细 */
    	function queryYsxx(userId){
    		StoreCache.setCache("tdYsid",userId);
    		window.open(contextRoot + 'tdgl/ysInformation.html');
    	}
    	
    	function initData(){
    		tdManagerData = StoreCache.removeCache("tdManagerData");

    		$.QuickRemote.AjaxJson(contextRoot + "tdgl/queryTdshxx", queryTdshxxBack, {TDID:tdManagerData.TDID});
    		
   			var shztObj = {'0':'新建','1':'待审核','2':'正常','3':'审核不通过','4':'已解散'};

   			var isRemoveWhtd = true,
            	SHZT = tdManagerData.SHZT;
            if(tdManagerData.USERID==parent.userInfo.USERID && (SHZT == 0 || SHZT == 3 )){
                isRemoveWhtd = false;
            }else if(isBoss && (SHZT == 0 || SHZT == 2)){
                isRemoveWhtd = false;
            }
            if(isRemoveWhtd){
                $("#whtd").remove(); //删除维护按钮
			}
			//3：审核不通过，4：已解散
            if(!isBoss || tdManagerData.SHZT == 3 || tdManagerData.SHZT == 4){ //tdManagerData.SHZT != 2
				$("#jstd").remove(); //删除解散按钮
   			}

   			if(tdManagerData.SHZT != 0 || isBoss){
   				$("#tjsh").remove();
   			}
   			if(StoreCache.removeCache("isPtgly")){
   				$("#foot button:not(#fh)").remove();
   			}
   			tdManagerData.SHZT_ = shztObj[tdManagerData.SHZT];
   			$("#tdjbxxForm [type=text]").each(function(){
   				var key = $(this).attr("name");
   				$(this).val(tdManagerData[key]);
   			})
   			
    		$("#cylbTable").data("TDID",tdManagerData.TDID).datagrid("reload", {"url": contextRoot + "tdgl/queryTdcylbAll.service"});
    		
    	}
    	
    	/** 查询审核信息回调 */
    	function queryTdshxxBack(result){
    		if(result.state){
    			if(StringUtils.isEmpty(result.SHID)){
    				if(isBoss){
    					$("#shDiv").remove();
    				}else{
	    				$("#noneSh").html("团队未曾发起审核申请");
	    				$("#shxxDiv").hide();
	    				$("#shDiv").css("height","40px")
    				}
    			}else{
    				result.SHTJSJ = result.SHTJSJ.substring(0,10);
    				if(result.SHSJ){
    					result.SHYH='医院管理员';
    					result.SHSJ=result.SHSJ.substring(0,10);
    					if(result.SHBTGYY){
    						result.SHZT='审核不通过';
    					}else{
    						result.SHZT='审核通过';
    						$('.hide1').hide();
    					}
    				}else{
    					result.SHZT='未审核';
    				}
    				for(var key in result){
    					$("#shxxDiv [name="+ key +"]").val(result[key]);
    				}
    			}
    		}else{
    			$.QuickAlert.alertFail({content: "审核信息丢了，稍后再加载一次吧！"});
    		}
    	}
    	
    	/** 跳转到列表页面  */
    	function toIndex(){
    		$.QuickUrlUtils.redirectUrl("index.html");
    	}
    	
    	
    	/** 维护团队  */
       	function toManager(){
	   		tdManagerData.type='update';
	   		StoreCache.setCache("tdManagerData",tdManagerData);
	   		StoreCache.setCache('forbackUrl','detail.html');
	   		StoreCache.setCache("isBoss",isBoss);
	   		$.QuickUrlUtils.redirectUrl("manager.html");
	   	}
    	
    	/** 查看团队日记  */
    	function toLogs(){
    		StoreCache.setCache("tdManagerData",tdManagerData);
	   		parent.layer.open({
				  type: 2,
				  area: ["60%", "500px"],
				  content: contextRoot + 'tdgl/logs.html',
				  scrollbar: false,
				  resize: false,
				  title:'团队日志',
				  end: function(){
					  if(StoreCache.removeCache("refresh",true)){
						  $.QuickUrlUtils.redirectUrl("yfprw.html");
					  }
				  }
			});
    	}
    	
    	/** 解散团队  */
       	function  deleteTdxx(){
   	   		$.QuickAlert.alertConfirm({
   				content : "解散团队后不可恢复，是否继续？",
   				callback : function() {
   					tdManagerData.SHZT = 4; //已解散
   					tdManagerData.TDZT = 0; //不可用
   					tdManagerData.JGID = parent.userInfo.PTJGID;
   					tdManagerData.CZRID = parent.userInfo.USERID;
   			   		$.QuickRemote.AjaxJson(contextRoot + "tdgl/delete", handleBack, tdManagerData);
   				}
   			})
       	}
       	/** 解散团队回调  */
       	function handleBack(result){
       		if(result.state){
    	   		$.QuickAlert.alertNormal(result.info.success, {callback: function(){
    	   			$.QuickUrlUtils.redirectUrl("index.html");
    			}});
       		}else{
       			$.QuickAlert.alertFail({content: result.info["faultInfo"]});
       		}
       	}
       	
       	/** 提交审核  */
       	function checkTdxx(){
       		var params = $.extend({CZRID:parent.userInfo.USERID},tdManagerData);
       		$.QuickRemote.AjaxJson(contextRoot + "tdgl/submitCheck", handleBack, params);
       	}
    </script>
  </head>
   <body class="easyui-layout" border="false">
   
   <div region="center" border="false">
   		<div style="height:170px;">
   			<div class="easyui-layout" fit="true" border="false">
					<div region="center" class="table-responsive" border="false"  style="overflow:hidden">
	   					<div class="title">
	   						<span>团队基本信息</span>
	   						<button class="btn btn-primary" onclick="toLogs()" style="position:absolute;top:5px;right:26px">查看团队日志<tton>
	   					</div>
						<table class="form-table" id="tdjbxxForm">
							<tr>
								<td class="td-text">团队名称</td>
								<td>
									<input type="text" class="form-control" name="TDMC" disabled="disabled"/>
								</td>
								<td class="td-text">团队状态</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="SHZT_"/>
								</td>
								<td class="td-text">所属医疗机构</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="YLJGMC"/>
								</td>
							</tr>
							<tr>
								
								<td class="td-text">团队队长</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="DZXM" />
								</td>
								<td class="td-text">手机号码</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="LXDH" />
								</td>
								<td class="td-text">创建时间</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="CJSJ"/>
								</td>
							</tr>
							<tr>
								<td class="td-text">联系地址</td>
								<td>
									<input type="text" disabled="disabled" class="form-control" name="LXDZ" />
								</td>
								<td class="td-text">团队简介</td>
								<td colspan="3">
									<input type="text" disabled="disabled" class="form-control" name="TDJJ" style="width:95.7%"/>
								</td>
							</tr>
						</table>
					</div>
   			</div>
   		</div>
   		
   		
   		<div style="margin-top:5px;" id="myBox">
   			<div class="easyui-layout" fit="true" border="false" id="myLayout">
   				<div region="north" style="height:40px;overflow:hidden" border="false">
   					<div class="title">成员列表</div>
   				</div>
   				<div region="center" border="false">
   					<table id="cylbTable" fit="true" style="border:1px solid #ddd"></table>
   				</div>
   			</div>
   		</div>
   		
   		<div id="shDiv" style="height:140px;margin-top:8px;">
   			<div class="easyui-layout" fit="true" border="false">
   				<div region="north" style="height:40px;overflow:hidden" border="false">
   					<div class="title">审核信息&nbsp;&nbsp;<span id="noneSh" style="color:red"></span></div>
   				</div>
   				<div region="center" id="shxxDiv" border="false">
   					<table class="form-table">
						<tr>
							<td class="td-text">提交时间</td>
							<td class="td-content">
								<input type="text" name="SHTJSJ" disabled="disabled"/>
							</td>
							<td class="td-text">审核时间</td>
							<td class="td-content">
								<input type="text" disabled="disabled" name="SHSJ"/>
							</td>
							<td class="td-text">审核用户</td>
							<td class="td-content" >
								<input type="text" disabled="disabled" name="SHYH"/>
							</td>
						</tr>
						<tr>
							<td class="td-text">审核状态</td>
							<td class="td-content">
								<input type="text" disabled="disabled" class="form-control check" name="SHZT"/>
							</td>
							<td class="td-text hide1">备注</td>
							<td class="td-content" colspan="3">
								<input type="text" class="hide1" name="SHBTGYY" disabled="disabled" style="width:96%;"/>
							</td>
						</tr>
					</table>
   				</div>
   			</div>
   		</div>
   		
   		
   </div>
   
   <div region="south" style="height:55px;line-height:55px;text-align:center;overflow:hidden;border:0;border-top:1px solid #ddd" id="foot">
   				  <button class="btn btn-primary" onclick="checkTdxx()" id="tjsh">提交审核<tton>
				  <button class="btn btn-primary" onclick="deleteTdxx()" id="jstd">解散团队<tton>
				  <button class="btn btn-primary" onclick="toManager()"  id="whtd">团队维护<tton>
				  <button class="btn btn-default" onclick="toIndex()" id="fh">返回<tton>
   </div>
   		
  </body>
</html>
